//
//  QianyueTableViewController.m
//  xingfugangwan
//
//  Created by rainday on 14/12/17.
//  Copyright (c) 2014年 rainday. All rights reserved.
//

#import "QianyueTableViewController.h"
#import "GoodsTableViewController.h"
#import "CartViewController.h"
#import <ReactiveCocoa.h>
#import <RACEXTScope.h>
#import "XFGWCart.h"

#define LIST @[@"拱门",@"摄影摄像",@"硬件设备",@"歌舞",@"软装",@"鲜花",@"喷绘",@"其他"]

@interface QianyueTableViewController ()
@property (nonatomic ,readonly) NSDictionary *dictionary;
@property (nonatomic ,readonly) UILabel *numLabel;

@end

@implementation QianyueTableViewController
static NSString *reuseIdentify = @"Cell";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:reuseIdentify];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    
   
    
    
    self.navigationItem.title = @"签约";
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
//    UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"购物车"] style:UIBarButtonItemStyleDone target:self action:@selector(showCart:)];
//    self.navigationItem.rightBarButtonItem = right;
//    
    
    
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightButton setImage:[UIImage imageNamed:@"购物车"] forState:UIControlStateNormal];
    [rightButton setFrame:CGRectMake(0, 0, 44, 44)];
    [rightButton addTarget:self action:@selector(showCart:) forControlEvents:UIControlEventTouchUpInside];
    
    
    _numLabel = [[UILabel alloc] initWithFrame:CGRectMake(24, 0, 20, 20)];
    _numLabel.backgroundColor = [UIColor redColor];
    _numLabel.layer.cornerRadius = 10;
    _numLabel.layer.masksToBounds = YES;
    _numLabel.text = @"0";
    _numLabel.textColor = [UIColor whiteColor];
    _numLabel.textAlignment = NSTextAlignmentCenter;
    [rightButton addSubview:_numLabel];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    
    
    
    
    NSArray *gongmen = @[@"龙凤门",@"纱门红色",@"纱门黄色",@"纱门白色",@"纱门粉色",@"绢花门",@"气球门",@"Love门",@"金象4米",@"金象5米",@"金象6米",@"生日门",@"单元门",@"双喜门",@"龙珠门",@"15米金门配5米大象",@"会议门",@"空飘",@"皇冠门（黄色）",@"皇冠门（红色）",@"皇冠门（白色）",@"门庭配绣球",@"15米拱门",@"气球引路",@"造型拱门",@"气球墙"];
    NSArray *sheying = @[@"摄影（标清/5D2/5D3）",@"摄像（标清/5D2/5D3",@"摇臂（标清/高清5D",@"转播"];
    NSArray *yingjian = @[@"LED大屏——彩屏（p3)",@"LED大屏——彩屏（p5）",@"LED大屏——彩屏（p6）",@"户外屏（p2）",@"户外屏（p5）",@"户外屏（p6)",@"LED灯",@"帕灯",@"追光（2500w）",@"追光（4000w）",@"光束灯（200w)",@"光束灯（230w)",@"光束灯(260w)",@"音响——普通（单十五)",@"音响——普通(双十五)",@"T台（普通)",@"T台（铝合金)",@"T台围子",@"图案灯（1200型)",@"图案灯（1500型)",@"干冰机",@"烟机/泡机",@"激光",@"喷绘",@"TRASS架",@"投影"];
    NSArray *gewu = @[@"西洋乐（迎宾/伴奏)",@"水鼓中国龙",@"激情水鼓",@"盛世鼓舞",@"青花瓷",@"一拍即合",@"舞蹈",@"民乐",@"动感",@"魔术+小丑",@"锣鼓",@"舞狮",@"礼仪"];
    
    NSArray *ruanzhuang = @[@"帷幔",@"花厅",@"罗马柱",@"羊绒毯(白)",@"羊绒毯(红)",@"镜面地毯",@"喷绘地毯",@"椅套/椅背"];
    NSArray *penhun = @[@"普通写真",@"水牌（画架）",@"展架",@"易拉宝",@"KT板（异形)",@"KT板（异形)",@"条幅",@"桌卡",@"X展架"];
    NSArray *qita = @[@"花使",@"化妆",@"婚纱",@"车队",@"锣鼓",@"军乐",@"主持",@"四季之水",@"香槟塔",@"蛋糕",@"甜品区",@"冰雕",@"钢琴",@"中式道具",@"OTO",@"录音/录歌/电子相册"];
    
    NSArray *xianhua = @[@"路引花",@"手捧花",@"胸花",@"腕花",@"鲜花门（全鲜花)",@"鲜花门（半鲜花)"];
    
    _dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:gongmen,@"拱门",sheying,@"摄影摄像",yingjian,@"硬件设备",gewu,@"歌舞",ruanzhuang,@"软装",penhun,@"喷绘",qita,@"其他",xianhua,@"鲜花", nil];
    
    
    
}


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    _numLabel.text = [NSString stringWithFormat:@"%lu",(unsigned long)[[[XFGWCart shareCart] dictionary] count]];
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [LIST count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 66;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentify forIndexPath:indexPath];
    
    // Configure the cell...
    if(indexPath.row >= [LIST count]) nil;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = LIST[indexPath.row];
    cell.imageView.image = [UIImage imageNamed:cell.textLabel.text];
    return cell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/


#pragma mark - Table view delegate

// In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here, for example:
    // Create the next view controller.
   
    GoodsTableViewController *goodsTableViewController = [[GoodsTableViewController alloc] init];
    
    for (id object in _dictionary) {
        if ([object isEqualToString:LIST[indexPath.row]]) {
           
            goodsTableViewController.data = [NSArray arrayWithArray:[_dictionary objectForKey:object]];
            NSLog(@"%@",goodsTableViewController.data);
        }
    }
    
    // Pass the selected object to the new view controller.
    [self.navigationController pushViewController:goodsTableViewController animated:YES];
    // Push the view controller.
   
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/


- (void)showCart:(id)sender
{
    CartViewController *cartViewController = [[CartViewController alloc] initWithNibName:@"CartViewController" bundle:nil];
    cartViewController.orderId = self.orderId;
    
    [self.navigationController pushViewController:cartViewController animated:YES];
}
@end
